



#include<iostream>
#include<vector>
using namespace std;
class Solution
{
    // 扔进去AC了他
public:
    int removeElement(vector<int>& nums, int val)
    {
        int n = nums.size();
        if (n <= 0)
            return n;
        //判断无输入
        int number = -1;//标记计数
        for (int i=0; i < n ; i++)
        {
            if(nums[i]!=val)
            {
                number++;
                nums[number]=nums[i];
            }
        }
        number+=1; //标记+1即为数字个数
        return number;
    }
};


int main() {
    int a[] = {0,3,1,3,3,12,12,12,21};
    int n = sizeof(a)/sizeof(a[0]);
    vector<int> arr(a,a+n);
    int newSize = Solution().removeElement(arr,5);
    for(int i=0;i<newSize;i++)
        cout<<arr[i]<<" ";
    cout<<endl;
    return 0;
}